#include <stdio.h>
#include <math.h>

void fromIntToBinary(const float *number);

int main(int argc, char *argv[]) {

	float num = 30;
	fromIntToBinary(&num);
}

void fromIntToBinary(const float *number) {
	
	float copyNumber = *number;

	// buffer count for binary
	char buffer[80];
	size_t buffer_id = 0;

	// cicle for translate from numbers to binary
	while (copyNumber > 0) {
		
		// for integer
		if (floor(copyNumber) == copyNumber) {
			if (copyNumber != *number) {
				buffer[buffer_id] = '0';
			}
		// for float
		} else {
			copyNumber = (int)copyNumber;
			if (copyNumber != *number) {
				buffer[buffer_id] = '1';
			}
		}
		
		buffer_id++;
		copyNumber = copyNumber / 2;
	}

	// output binary numbers in reverse order
	for(size_t id = (buffer_id - 1); id > 0; id--) {
		printf("%c", buffer[id]);
	}
}
